<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // eval():计算字符串表达的值，并执行其中的JavaScript代码.
        var str = "5+6";
        alert(eval(str));


        var str1 = "x+y";
        var x = 10,y = 20;
        console.log(eval(str1));


        var index = "if(a>b){a-b} else(b-a)"
        var a=11,b=10;
         document.write(eval(index))




         //encodeURL()使用ISO8859-1对字符串进行编码，每个UTF-8的汉字被编码成3个16进制字节。decodeURL()反之对字符串进行解码。
         var names = "高伟杰";
         console.log(encodeURI(names));//%E9%AB%98%E4%BC%9F%E6%9D%B0

         var unnames = "%E9%AB%98%E4%BC%9F%E6%9D%B0"
         console.log(decodeURI(unnames));//高伟杰



         //escape（）使用Unicode对字符串进行编码，每个UTF-8汉字被编码成一盒双字节16进制的转义字符%uXXXX。unescape()反之对字符串进行解码
         var gwj = "大家好";
         console.log(escape(gwj));//%u5927%u5BB6%u597D

         var gwjjyo = "%u5927%u5BB6%u597D";
         console.log(unescape(gwjjyo));//大家好
         
    </script>
</body>
</html>